<template>
	<om-formsub-outer :index="index" :checkedit="checkedit" :deleteBtn="false">
		<om-autoform ref="autoform" :initConfigData="autoformdata" :initValue="initValue"></om-autoform>
	</om-formsub-outer>
</template>

<script>
	import {buildSubFormData, subOnLoad, changeEditor,configSelectData,hasValue} from '@/static/js/formUtil.js';
	import { ignoreHtml,ptFloat,minusF,getDateStr} from '@/static/js/common.js';
	import { mapState } from 'pinia';
	import {useLoginUserStore} from '@/stores/login-user.js';
	export default {
		provide() {
			return {
				formPage: this
			};
		},
		data() {
			return buildSubFormData({
				parentId:'',
				otherId:''
			})
		},
		computed: {
			...mapState(useLoginUserStore, ['userName', 'userId'])
		},
		methods:{
			initLoad(){
				let _that = this
				let arr = [
					_that.om.request(
						"subjectDict/showScoreCombo",
						{
							itemId:_that.formdata.itemId
						}
					)
				]
				Promise.all(arr).then(res=>{
					if(_that.parentId == _that.userId){
						_that.$refs.autoform.changeEditor("title_evaluate","selfEvaluateScore","type",'labelbox')
						_that.$refs.autoform.changeEditor("title_evaluate","parentEvaluateScore",'type','selectbox')
						_that.$refs.autoform.changeEditor("title_evaluate","parentEvaluateScore",'data',configSelectData(res[0],'value','name'))
						_that.$refs.autoform.initSelectIndex("title_evaluate","parentEvaluateScore")
					}else if(_that.userId == _that.otherId){
						_that.$refs.autoform.changeEditor("title_evaluate","parentEvaluateScore","type",'labelbox')
						_that.$refs.autoform.changeEditor("title_evaluate","selfEvaluateScore",'type','selectbox')
						_that.$refs.autoform.changeEditor("title_evaluate","selfEvaluateScore",'data',configSelectData(res[0],'value','name'))
						_that.$refs.autoform.initSelectIndex("title_evaluate","selfEvaluateScore")
					}else{
						_that.$refs.autoform.changeEditor("title_evaluate","parentEvaluateScore","type",'labelbox')
						_that.$refs.autoform.changeEditor("title_evaluate","selfEvaluateScore","type",'labelbox')
					}
				})
			}
		},
		onShow() {
			
		},
		onLoad(e) {
			let _that = this
			if(e.parentId){
				_that.parentId = e.parentId
			}
			if(e.otherId){
				_that.otherId = e.otherId
			}
			subOnLoad(_that, e, function() {
			if(e.configDataCacheKey){
				uni.getStorage({
					key: e.configDataCacheKey,
					success: function(res) {
						if(res.data && Object.prototype.toString.call(res.data)==='[object Array]'){
							_that.autoformdata = res.data
							Object.assign(_that.initValue, _that.formdata)
							_that.autoformdata[0].order = _that.order
								_that.initLoad()
							}
						}
					})
				}
			})
		}
	}
</script>

<style>
</style>                                                                                                                                                                                                                                                                                                                                                                                                                                                         
